#!/bin/bash
set -e

CONVOY_CONTENT="convoy"

cd $(dirname $0)/..

if [ ! -x bin/convoy ]; then
    scripts/build
fi

rm -rf dist/artifacts

mkdir -p build/${CONVOY_CONTENT}
mkdir -p dist/artifacts

cp /usr/local/bin/convoy-pdata_tools bin/
cp -f bin/* build/${CONVOY_CONTENT}

cd build

sha1sum -b $(find ${CONVOY_CONTENT} -type f) > ${CONVOY_CONTENT}/SHA1SUMS

tar czf ../dist/artifacts/convoy.tar.gz ${CONVOY_CONTENT}
echo Created dist/artifacts/convoy.tar.gz
